package com.cloudbroker.openapi.manage.controller;

import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.viewpoint.result.*;
import com.cloudbroker.bcs.platform.ltb.bizapi.service.viewpoint.vo.*;
import com.cloudbroker.bcs.platform.ltb.bizapi.t2service.social.ViewPointT2BizService;
import com.cloudbroker.bcs.platform.ltb.common.ext.annotation.SaveLog;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import static com.cloudbroker.bcs.platform.ltb.common.util.RequestUtil.getSingleParameterMapForBody;

/**
 * Created by tianrui on 2016/7/9.
 */

@Controller
public class ViewPointController {

    @Resource
    private ViewPointT2BizService viewPointT2BizService;


    @ResponseBody
    @RequestMapping("/viewpointmsg_add")
    @SaveLog(remark = "添加观点")
    public ViewpointSaveResult saveViewpointMsg(HttpServletRequest request, String jsonpcallback){
        ViewpointSaveForm form = getSingleParameterMapForBody(request , ViewpointSaveForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcViewpointSaveResult(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_qry")
    @SaveLog(remark = "观点展示(投顾)")
    public ViewpointList queryViewpointMsg(HttpServletRequest request, String jsonpcallback) {
        ViewpointQueryForm form = getSingleParameterMapForBody(request, ViewpointQueryForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcViewpointList(form), jsonpcallback);
    }


    @ResponseBody
    @RequestMapping("/viewpointmsg_recom_qry")
    @SaveLog(remark = "查询观点(粉丝)")
    public ViewpointRecomList queryViewpointRecomMsg(HttpServletRequest request,
                                                     String jsonpcallback) {
        ViewpointRecomQueryForm form = getSingleParameterMapForBody(request, ViewpointRecomQueryForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcViewpointRecomList(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_upvote")
    @SaveLog(remark = "观点点赞")
    public ViewpointUpvoteResult upvoteViewpoint(HttpServletRequest request, String jsonpcallback) {
        ViewpointUpvoteForm form = getSingleParameterMapForBody(request, ViewpointUpvoteForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcUpvoteViewpoint(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_share")
    @SaveLog(remark = "观点分享")
    public ViewpointShareResult shareViewpoint(HttpServletRequest request, String jsonpcallback) {
        ViewpointShareForm form = getSingleParameterMapForBody(request, ViewpointShareForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcShareViewpoint(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_mod")
    @SaveLog(remark = "观点修改")
    public ViewpointSaveResult updateViewpoint(HttpServletRequest request, String jsonpcallback) {
        ViewpointUpdateForm form = getSingleParameterMapForBody(request, ViewpointUpdateForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcUpdateViewpoint(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/adviser_viewpoint_qry")
    @SaveLog(remark = "查询投顾的观点")
    public ViewpointRecomList queryAdviserViewpoint(HttpServletRequest request, String jsonpcallback) {
        AdviserViewpointQueryForm form = getSingleParameterMapForBody(request, AdviserViewpointQueryForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcQueryAdviserViewpoint(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_recommend_qry")
    @SaveLog(remark = "查询推荐观点")
    public ViewpointRecomList queryRecommendViewpoint(HttpServletRequest request, String jsonpcallback) {
        ViewpointRecomQueryForm form = getSingleParameterMapForBody(request, ViewpointRecomQueryForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcQueryRecommendViewpoint(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_close")
    @SaveLog(remark = "观点屏蔽")
    public ViewpointSaveResult viewpointmsgClose(HttpServletRequest request, String jsonpcallback) {
        ViewPointIdForm form = getSingleParameterMapForBody(request, ViewPointIdForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcCloseViewpoint(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_close_cancel")
    @SaveLog(remark = "观点屏蔽取消")
    public ViewpointSaveResult viewpointmsgCloseCancel(HttpServletRequest request, String jsonpcallback) {
        ViewPointIdForm form = getSingleParameterMapForBody(request, ViewPointIdForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcCancelCloseViewpoint(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_detail")
    @SaveLog(remark = "观点详情")
    public ViewpointDetailResult viewpointmsgDetail(HttpServletRequest request, String jsonpcallback) {
        ViewPointIdForm form = getSingleParameterMapForBody(request, ViewPointIdForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcViewpointDetail(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_tag_qry")
    @SaveLog(remark = "观点标签列表")
    public ViewpointTagListResult viewpointmsgTagList(HttpServletRequest request, String jsonpcallback) {
        ViewpointTagQueryForm form = getSingleParameterMapForBody(request, ViewpointTagQueryForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcQueryViewpointTagList(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_topic_qry")
    @SaveLog(remark = "观点话题列表")
    public ViewpointTopicListResult viewpointmsgTopicList(HttpServletRequest request, String jsonpcallback) {
        ViewpointTopicQueryForm form = getSingleParameterMapForBody(request, ViewpointTopicQueryForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcQueryViewpointTopicList(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_topic_detail")
    @SaveLog(remark = "观点话题详情")
    public ViewpointTopicDetailResult viewpointTopicDetail(HttpServletRequest request, String jsonpcallback) {
        ViewpointTopicDetailForm form = getSingleParameterMapForBody(request, ViewpointTopicDetailForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcViewpointTopicDetail(form), jsonpcallback);
    }

    @ResponseBody
    @RequestMapping("/viewpointmsg_search")
    @SaveLog(remark = "观点搜索")
    public ViewpointRecomList viewpointMsgSearch(HttpServletRequest request, String jsonpcallback) {
        ViewpointQueryForm form = getSingleParameterMapForBody(request, ViewpointQueryForm.class);
        return VOUtil.setJsonpResult(viewPointT2BizService.funcViewpointSearch(form), jsonpcallback);
    }
}
